package com.sbc.liteflow.component.recharge;

import com.sbc.liteflow.dto.ElectronicAccount;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.NodeComponent;
import org.springframework.util.StringUtils;

/**
 * @Description: 充值前置功能
 * @Author: songbaicheng
 * @Create: 2024/11/30 11:18
 **/
@LiteflowComponent("pre_recharge")
public class PreRechargeComponent extends NodeComponent {

    /**
     * 进入节点的前置判断
     */
    @Override
    public boolean isAccess() {
        return StringUtils.hasLength(this.getSlot().getRequestData());
    }

    @Override
    public void process() throws Exception {
        String corpId = this.getSlot().getRequestData();

        // 业务逻辑
        System.out.println("根据 corpId ：【" + corpId + "】查询判断绑定银行卡不存在、电子账户不存在");

        // 创建一个虚拟账户对象（假设你查询到的数据是一个对象）
        ElectronicAccount electronicAccount = new ElectronicAccount();
        electronicAccount.setSetAccountNo("1234567890");
        electronicAccount.setSetAccountName("虚拟账户");

        // 将对象存入上下文
        this.getSlot().setChainReqData("electronicAccount", electronicAccount);
    }
}
